package com.jeeplus.modules.sys.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sys.entity.DaiBanTongJi;
import com.jeeplus.modules.sys.mapper.DaiBanTongJiMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author xujin
 * @title: DaiBanTongJiService
 * @projectName ESA
 * @description: TODO
 * @date 2019-12-039:48
 */
@Service
@Transactional(readOnly = true)
public class DaiBanTongJiService extends CrudService<DaiBanTongJiMapper, DaiBanTongJi> {

    @Autowired
    DaiBanTongJiMapper daiBanTongJiMapper;

    @Transactional(readOnly = false)
    public Page<DaiBanTongJi> findPage(Page<DaiBanTongJi> page, DaiBanTongJi daiBanTongJi) {
        dataRuleFilter(daiBanTongJi);
        List<DaiBanTongJi> list = daiBanTongJiMapper.findList1(daiBanTongJi,page);
        page.setList(list);
        daiBanTongJi.setPage(page);
        if(list != null && list.size() > 0){
            page.setCount(list.get(0).getCount());
        }else {
            page.setCount(0);
        }
        return page;
    }

    @Transactional(readOnly = false)
    public List<DaiBanTongJi> findList1(String company) {
        return daiBanTongJiMapper.findList2(company);
    }
}
